/**
 */
package de.thwildau.tm.moses.asn1.asn1.impl;

import de.thwildau.tm.moses.asn1.asn1.AnyDefinedNamedType;
import de.thwildau.tm.moses.asn1.asn1.Asn1Package;
import de.thwildau.tm.moses.asn1.asn1.NamedType;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Any Defined Named Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.AnyDefinedNamedTypeImpl#getName <em>Name</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.AnyDefinedNamedTypeImpl#getDefinedType <em>Defined Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AnyDefinedNamedTypeImpl extends ComponentTypeImpl implements AnyDefinedNamedType
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getDefinedType() <em>Defined Type</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDefinedType()
   * @generated
   * @ordered
   */
  protected NamedType definedType;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected AnyDefinedNamedTypeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Asn1Package.Literals.ANY_DEFINED_NAMED_TYPE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.ANY_DEFINED_NAMED_TYPE__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NamedType getDefinedType()
  {
    if (definedType != null && definedType.eIsProxy())
    {
      InternalEObject oldDefinedType = (InternalEObject)definedType;
      definedType = (NamedType)eResolveProxy(oldDefinedType);
      if (definedType != oldDefinedType)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, Asn1Package.ANY_DEFINED_NAMED_TYPE__DEFINED_TYPE, oldDefinedType, definedType));
      }
    }
    return definedType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NamedType basicGetDefinedType()
  {
    return definedType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDefinedType(NamedType newDefinedType)
  {
    NamedType oldDefinedType = definedType;
    definedType = newDefinedType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.ANY_DEFINED_NAMED_TYPE__DEFINED_TYPE, oldDefinedType, definedType));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Asn1Package.ANY_DEFINED_NAMED_TYPE__NAME:
        return getName();
      case Asn1Package.ANY_DEFINED_NAMED_TYPE__DEFINED_TYPE:
        if (resolve) return getDefinedType();
        return basicGetDefinedType();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Asn1Package.ANY_DEFINED_NAMED_TYPE__NAME:
        setName((String)newValue);
        return;
      case Asn1Package.ANY_DEFINED_NAMED_TYPE__DEFINED_TYPE:
        setDefinedType((NamedType)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.ANY_DEFINED_NAMED_TYPE__NAME:
        setName(NAME_EDEFAULT);
        return;
      case Asn1Package.ANY_DEFINED_NAMED_TYPE__DEFINED_TYPE:
        setDefinedType((NamedType)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.ANY_DEFINED_NAMED_TYPE__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case Asn1Package.ANY_DEFINED_NAMED_TYPE__DEFINED_TYPE:
        return definedType != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //AnyDefinedNamedTypeImpl
